package com.yunnuo.system.domain;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户表
 * Created by 魏洪福(15064000912@163.com) on  2018/5/25.
 */
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    //用户id
    private Integer id;
    //登录名
    private String loginName;
    //真实姓名
    private String realName;
    //用户密码
    private String password;
    //部门id
    private String deptId;
    //部门全称
    private String deptName;
    //创建时间
    private Date createTime;
    //修改时间
    private Date updateTime;
    //用户状态(0 代表正常,1代表禁用)
    private String userStatus;
    //邮箱
    private String email;
    //手机号码
    private String phone;
    //性别
    private String sex;
    //盐加密
    private String salt;
    //角色
    private List<String> roleIds;

    public String getSalt()
    {
        return salt;
    }

    public void setSalt(String salt)
    {
        this.salt = salt;
    }

    /**
     * 生成随机盐
     */
    public void randomSalt()
    {
        // 一个Byte占两个字节，此处生成的3字节，字符串长度为6
        SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
        String hex = secureRandom.nextBytes(3).toHex();
        setSalt(hex);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getUserStatus() {
        return userStatus;
    }

    public void setUserStatus(String userStatus) {
        this.userStatus = userStatus;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public List<String> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<String> roleIds) {
        this.roleIds = roleIds;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", loginName='" + loginName + '\'' +
                ", realName='" + realName + '\'' +
                ", password='" + password + '\'' +
                ", deptId='" + deptId + '\'' +
                ", deptName='" + deptName + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", userStatus='" + userStatus + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", sex='" + sex + '\'' +
                ", salt='" + salt + '\'' +
                ", roleIds=" + roleIds +
                '}';
    }
}
